﻿using MySql.Data.EntityFrameworkCore.DataAnnotations;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;

namespace MyMusicList.DBModel
{
    /// <summary>
    /// 用户自身歌曲
    /// </summary>
    [MySqlCharset("utf8mb4")] //字符集,需要引用MySql.Data.EntityFrameworkCore
    [MySqlCollation("utf8mb4_general_ci")] //排序规则
    [Table("user_Music", Schema = "mymusic")]
    public class User_Music
    {
        [Key]
        //[NotMapped]
        public int User_Music_Id { get; set; }

        public int Sys_Music_Type_Id { get; set; }

        public string User_Music_name { get; set; }

        public int Sys_Music_Id { get; set; }

        [Column(TypeName = "bit")]
        /// <summary>
        /// 是否上架
        /// </summary>
        public bool Is_Upper_Shelf { get; set; }

        [Column(TypeName = "bit")]
        /// <summary>
        /// 是否被审核
        /// </summary>
        public bool Is_Audited { get; set; }

        [Column(TypeName = "bit")]
        /// <summary>
        /// 审核结果
        /// </summary>
        public bool Audited_Result { get; set; }
       
        /// <summary>
        /// 创建时间(用户创建)
        /// </summary>
        public DateTime? CreateTime { get; set; }
       
        /// <summary>
        /// 审核时间
        /// </summary>
        public DateTime? AuditedTime { get; set; }
       
        /// <summary>
        /// 存放路径
        /// </summary>
        public string Path { get; set; }
       
        public string Reamrk { get; set; }

        [Column(TypeName = "bit")]
        /// <summary>
        /// 是否标记删除
        /// </summary>
        public bool IsDel { get; set; }



        private DataDBContext _context;

        //[NotMapped]
        //private int Myid;
        public User_Music(DataDBContext context)
        {
            _context = context;
            //Myid = id;
        }

        public User_Music()
        {
          
        }

        public string Type_Name
        {
            get
            {
                if (this.Sys_Music_Type_Id != 0)
                {
                    var data = _context.Sys_Music_Type.Where(x => x.Sys_Music_Type_Id == this.Sys_Music_Type_Id).FirstOrDefault();
                    if (data != null)
                    {
                        return data.Sys_Music_Type_Name;
                    }
                    else
                    {
                        return "";
                    }
                }
                else
                {
                    return null;
                }
            }
            set
            {

            }
        }
    }
}
